/*
 * <copyright> Copyright 2000-2004 Cougaar Software, Inc. All Rights Reserved
 * </copyright>
 */
package com.marklogic.ps.servicetester.gui;

import java.awt.Component;

import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;

import com.marklogic.ps.servicetester.domain.Query;
import com.marklogic.ps.servicetester.domain.Service;
import com.marklogic.ps.servicetester.resources.Icons;

class QueryTreeCellRenderer extends DefaultTreeCellRenderer {

    public Component getTreeCellRendererComponent(JTree tree, Object value,
            boolean sel, boolean expanded, boolean leaf, int row,
            boolean hasFocus) {
        super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
                row, hasFocus);
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
        
        Object userObject = node.getUserObject();
        
        
        if (userObject instanceof Service) {
            setIcon(Icons.COG);
        } else if (userObject instanceof Query) {
        	setIcon(Icons.GREEN_DOT);
        } else if (node.isRoot()) {
        	setIcon(Icons.PACKAGE);
        }
        return this;
    }
}